# ========== Stage 1: Build Vue App ==========
FROM node:22-alpine as builder

WORKDIR /app
COPY package.json pnpm-lock.yaml ./

RUN apk add --no-cache git

RUN corepack enable && corepack prepare pnpm@latest --activate
RUN pnpm install

COPY . .
RUN pnpm run build

# ========== Stage 2: Nginx Serve ==========
FROM nginx:alpine

# 拷贝构建产物到 Nginx 静态目录
COPY --from=builder /app/dist /usr/share/nginx/html

EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
